package com.ftm.dao.impl;

import java.util.List;

import com.ftm.dao.GoodsTypeDao;
import com.ftm.entity.GoodsType;
import com.ftm.tools.DBTools;

public class GoodsTypeDaoImpl implements GoodsTypeDao {

	@Override
	public List<GoodsType> selGoodsType() {
		String sql = "select typename from ftm_goodstype";
		List<GoodsType> list = (List<GoodsType>) DBTools.exQuery(sql, GoodsType.class, null);
		return list;
	}

	@Override
	public boolean addGoodsType(GoodsType gt) {
		String sql = "insert into ftm_goodstype values(null,?,?)";
		int n = DBTools.exUpdate(sql, gt.getTypename(), gt.getTypeinfo());
		if (n > 0)
			return true;
		return false;
	}

	@Override
	public boolean molGoodsType(int typeid, String typename, String typeinfo) {
		String sql = "update ftm_goodstype set typename =?,typeinfo=? where typeid=?";
		int n = DBTools.exUpdate(sql, typename, typeinfo, typeid);
		if (n > 0)
			return true;
		return false;
	}

	@Override
	public boolean delGoodsType(String typename) {
		String sql = "delete from ftm_goodstype where typename=?";
		int n = DBTools.exUpdate(sql, typename);
		if (n > 0)
			return true;
		return false;
	}

	@Override
	public List<GoodsType> selGoodsTypeAll() {
		String sql = "select typeid,typename,typeinfo from ftm_goodstype";
		List<GoodsType> list = (List<GoodsType>) DBTools.exQuery(sql, GoodsType.class, null);
		return list;
	}

}
